#ifndef DATABASE_SDS_H
#define DATABASE_SDS_H

#include <string>

namespace DBServer
{
namespace Database
{
class Sds {
public:
    // constructor of sds
    Sds();
    ~Sds();
    Sds(const char*);
    Sds(const std::string&);
    Sds(const Sds&);
    Sds(const Sds&&);
    const Sds& operator=(const Sds&);
    const Sds& operator=(const Sds&&);
    bool operator==(const Sds&) const;

    // sds api
    int get_len();                  // get cur_len
    int get_vail();                 // get free_len
    char* get_raw();                // get raw char[]
    void clear();                   // lazy clear the data (only reset free_len and cur_len)
    void cat(const Sds&);           // append with other Sds
    void cat(const char*);          // append with c str
    void cat(const std::string&);   // append with stl string
    void grow_zero(int);            // expands sds to teh specified number of bytes and fill it with zeros
    bool compare(const Sds&);       // compare two sds to see if they are equal

private:
    unsigned int free_len;
    unsigned int cur_len;           // recode the string length
    char *sds;                      // include c string as data
};

} // namespace Database
} // namespace DBServer


#endif